package com.shipin.shangchuan.Lambda;

import com.shipin.shangchuan.model.Person;

import java.util.Arrays;
import java.util.Comparator;

public class Demo04Arrays {
    public static void main(String[] args) {
        Person[] arr = {
                new Person("hello", 28),
                new Person("judy", 18),
                new Person("moli", 19),
        };

        Arrays.sort(arr, new Comparator<Person>() {
            @Override
            public int compare(Person o1, Person o2) {
                return o1.getAge()-o2.getAge();
            }
        });


        Arrays.sort(arr,(Person o1, Person o2) -> {
            return o1.getAge()-o2.getAge();
        });

        for (Person p : arr) {
            System.out.println(p);
        }
    }
}
